<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
            func.call(thisObj, arg1, arg2 ...)
            调用一个函数，用thisObj替换函数中的this执行函数，argN代表函数的参数
            新的获取变量类型的方式
            Object.prototype.toString.call(变量)  ==>  "[object 变量的类型]"
        */

        var name = '张三';
        
        var obj = {
            name: 'Lina',
            sayName () {
                console.log(this.name);
                console.log(this);
            }
        }

        function sayLyric(str, strr) {
            console.log(this.name + '唱:' + str + strr);
        }

        // obj.sayName(); // lina
        // obj.sayName.call(window); // 张三
        obj.sayName.call('sss')
        // sayLyric('I am loser ', '西八');
        sayLyric.call('圈圈圆圆圈圈', '天天年年的我');
        // sayLyric.call();

        var ts = Object.prototype.toString;

        console.log('string', ts.call('123').search('String') !== -1); // true
        console.log('number', /number/i.test(ts.call(123)));
        console.log('boolean', ts.call(true));
        console.log('undefined', ts.call(undefined));
        console.log('null', ts.call(null));
        console.log('array', ts.call([]));
        console.log('object', ts.call({}));
        console.log('function', ts.call(function () {}));

		// 如果没有参数，并且第一个thisObj没有传，那么默认传递了window
        obj.sayName.call()
    </script>
</body>
</html>